<template>
  <div>
    <el-container>
      <el-header>
        <b>供应链金融审批</b>

        <div style="float: right">
          <!-- <el-upload
          class="avatar-uploader"
          action="http://localhost:8082/file/upload"
          :show-file-list="false"
          :on-success="handleAvatarSuccess"
          :before-upload="beforeAvatarUpload"
          style="float:left"
        >
          <img v-if="imageUrl" :src="imageUrl" class="avatar" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload> -->
          <el-button type="primary" @click="loginOut">退出</el-button>
        </div>
        
        
      </el-header>
      <el-container>
        <el-aside width="200px" class="test-wrap">
          <div style="height: 1200px; background-color: white">
            <el-menu class="menu-Bar">
              <menutree :menuData="menuData"></menutree>
            </el-menu>
          </div>
        </el-aside>
        <el-main><router-view /></el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
import menutree from "@/components/MenuTree.vue";
export default {
  components: {
    menutree,
  },
  data() {
    return {
      menuData: [
        {
          rmid: "",
          treemenu: {},
          children: [],
        },
      ],
      imageUrl: "",
    };
  },
  created() {
    this.getMenu();
  },

  methods: {
     getMenu() {
       this.menuData=JSON.parse(sessionStorage.getItem("tree"));
       
    },
    loginOut() {
      window.sessionStorage.clear();
      this.$router.push({ path: "/login" });
    },
    // handleAvatarSuccess(res, file) {
    //   this.imageUrl = URL.createObjectURL(file.raw);
    //    //1.得到文件
    //   console.log(file);
    //   // //2.将file封装到FormData  经常用来上传文件时封装数据得
    //   // let data = new FormData();
    //   // data.append("file", file);
    //   // this.$axios
    //   //   .post("http://localhost:8082/file/upload", data, {
    //   //     headers: {
    //   //       "Content-Type": "multipart/form-data",
    //   //     },
    //   //   })
    //   //   .then((resp) => {
    //   //     console.log(resp);
    //   //   });
    // },
    // beforeAvatarUpload(file) {
    //   const isJPG = file.type === "image/jpeg";
    //   const isLt2M = file.size / 1024 / 1024 < 2;

    //   if (!isJPG) {
    //     this.$message.error("上传头像图片只能是 JPG 格式!");
    //   }
    //   if (!isLt2M) {
    //     this.$message.error("上传头像图片大小不能超过 2MB!");
    //   }
    //   return isJPG && isLt2M;
    // },
  },
};
</script>
<style >
.test-wrap {
  background: rgb(84, 146, 228);
  border-radius: 0px 30px 30px 0px;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 30px;
  height: 30px;
  line-height: 30px;
  text-align: center;
}
.avatar {
  width: 30px;
  height: 30px;
  display: block;
}
</style>